{extend name="index_layout"/}
{block name="main"}
<form class="layui-form" method="post">
    <div class="layui-form-item" >
        <label class="layui-form-label">商品类型</label>
        <div class="layui-input-block">
            <select name="goods_cate" lay-verify="required" lay-filter="ccc6">
                <option value=""></option>
                {if !empty($goods_cate_list)}
                {foreach $goods_cate_list as $key}
                <option value="{$key.id}"  name="goods_cate"> {$key.name}</option>
<!--                <option <?php if( $key['id'] == $data['goods_cate']){ ?>selected<?php }?>value="{$key.id}"  name="goods_cate"> {$key.name}</option>-->
                {/foreach}
                {/if}
            </select>
        </div>
    </div>
<!--//0陪诊 1医疗用品 2优惠卷-->
<!--    <select name="object_id" lay-verify="required">-->
    <div class="layui-form-item c1" style="display: none;">
        <label class="layui-form-label">优惠卷</label>
        <div class="layui-input-block">
            <select name="object_id" id="c1">
                <option value=""></option>
                {if !empty($coupons_list)}
                {foreach $coupons_list as $key}
                <option <?php if( $key['id'] == $data['object_id']){ ?>selected<?php }?>value="{$key.id}"  name="object_id"> {$key.name}</option>
                {/foreach}
                {/if}
            </select>
        </div>
    </div>

    <div class="layui-form-item c2" style="display: none;">
        <label class="layui-form-label">陪诊服务</label>
        <div class="layui-input-block">
            <select name="pz_object_id" id="c2">
                <option value=""></option>
                {if !empty($server_list)}
                {foreach $server_list as $key}
                <option <?php if( $key['id'] == $data['object_id']){ ?>selected<?php }?>value="{$key.id}"  name="object_id"> {$key.name}</option>
                {/foreach}
                {/if}
            </select>
        </div>
    </div>

    <div class="layui-form-item c3" style="display: none;">
        <label class="layui-form-label">名称</label>
        <div class="layui-input-block">
            <input type="text" name="name" id="c3" autocomplete="off" placeholder="名称"
                   class="layui-input">
        </div>
    </div>

    <div class="layui-form-item c4" style="display: none;">
        <label class="layui-form-label">主图</label>
        <div class="layui-input-block">
            <input type="text" name="img" id="c-pic" value="" class="layui-input">
        </div>
        <div class="layui-input-block">
            <button type="button" class="layui-btn faupload" id="faupload-pic" data-multiple="false" data-input-id="c-pic"
                    data-preview-id="p-pic" data-type="image"><i class="layui-icon layui-icon-upload"></i> 上传
            </button>
            <button type="button" class="layui-btn fachoose" data-multiple="false" data-mimetype="image"
                    data-input-id="c-pic" id="fachoose-c-pic"><i class="iconfont icon-other"></i> 选择
            </button>
            <ul class="layui-row list-inline plupload-preview" id="p-pic"></ul>
        </div>
    </div>

    <div class="layui-form-item c5" style="display: none;">
        <label class="layui-form-label">规格说明</label>
        <div class="layui-input-block">
            <textarea id="c5" name="specs" placeholder="规格说明"  class="layui-textarea"></textarea>
        </div>
    </div>

    <div class="layui-form-item c6" style="display: none;">
        <label class="layui-form-label">内容详情</label>
        <div class="layui-input-block">
            <script type="text/plain" class="js-ueditor" name="content" id="c6"
                    style="width:900px;height:200px;position: relative;z-index: 1 !important;"
                    id="content"></script>
        </div>
    </div>


    <div class="layui-form-item">
        <label class="layui-form-label">所需积分</label>
        <div class="layui-input-block">
            <input type="number" name="points" lay-verify="required" autocomplete="off" placeholder="所需积分"
                   class="layui-input" >
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">排序</label>
        <div class="layui-input-block">
            <input type="Number" name="sort" lay-verify="required" autocomplete="off" placeholder="排序"
                   class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">库存</label>
        <div class="layui-input-block">
            <input type="Number" name="inventory" lay-verify="required" autocomplete="off" placeholder="库存"
                   class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">已兑换数量</label>
        <div class="layui-input-block">
            <input type="Number" name="salenum" lay-verify="required" autocomplete="off" placeholder="已兑换数量"
                   class="layui-input">
        </div>
    </div>




    <div class="layui-form-item layer-footer">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
{/block}
{block name="script"}
<!--//0陪诊 1医疗用品 2优惠卷-->
<script type="text/javascript">
    layui.use(['yznForm','form'], function () {
        var yznForm = layui.yznForm;
        var form = layui.form;
        var $ = layui.jquery;
        yznForm.bindevent($("form.layui-form"));
        form.on('select(ccc6)',function(data){
            select_data=data.value;
            console.log(select_data);
            if (select_data==2){
                $(".c1").show();
                var element = document.getElementById("c1");
                element.setAttribute("lay-verify", "required");
                $(".c2").hide();
                var element2 = document.getElementById('c2');
                element2.removeAttribute('lay-verify');

                $(".c3").hide();
                $(".c4").hide();
                $(".c5").hide();
                $(".c6").hide();
                var element3 = document.getElementById('c3');
                element3.removeAttribute('lay-verify');
                var element4 = document.getElementById('c-pic');
                element4.removeAttribute('lay-verify');
                var element5 = document.getElementById('c5');
                element5.removeAttribute('lay-verify');

            }
            if (select_data==0){
                $(".c1").hide();
                var element = document.getElementById('c1');
                element.removeAttribute('lay-verify');
                $(".c2").show();
                var element2 = document.getElementById('c2');
                element2.setAttribute("lay-verify", "required");

                $(".c3").hide();
                $(".c4").hide();
                $(".c5").hide();
                $(".c6").hide();
                var element3 = document.getElementById('c3');
                element3.removeAttribute('lay-verify');
                var element4 = document.getElementById('c-pic');
                element4.removeAttribute('lay-verify');
                var element5 = document.getElementById('c5');
                element5.removeAttribute('lay-verify');
            }
            if (select_data==1){
                $(".c1").hide();
                $(".c2").hide();
                var element1 = document.getElementById('c1');
                element1.removeAttribute('lay-verify');
                var element2 = document.getElementById('c2');
                element2.removeAttribute('lay-verify');


                $(".c3").show();
                $(".c4").show();
                $(".c5").show();
                $(".c6").show();
                var element3 = document.getElementById('c3');
                element3.setAttribute("lay-verify", "required");
                var element4 = document.getElementById('c-pic');
                element4.setAttribute("lay-verify", "required");
                var element5 = document.getElementById('c5');
                element5.setAttribute("lay-verify", "required");
            }
            form.render();
        });
    });

</script>
{/block}